/* ========================================================================= */
/* ------------------------------------------------------------------------- */
/*!				\file		CC_DrawSpace.cc
				\date		june 2010
				\author		TNick

				\brief		Implements CC_DrawSpace class


	~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	Please read ReadMe.txt and Licence.txt in root folder
	~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


*/
/* ------------------------------------------------------------------------- */
/* ========================================================================= */
//
//
//
//
/*  INCLUDES    ------------------------------------------------------------ */

#include	"../main.h"

#include	<assert.h>

#include	"CC_App.h"
#include	"CC_GraphItemProp.h"

/*  INCLUDES    ============================================================ */
//
//
//
//
/*  DEFINITIONS    --------------------------------------------------------- */


/*  DEFINITIONS    ========================================================= */
//
//
//
//
/*  DATA    ---------------------------------------------------------------- */



/*  DATA    ================================================================ */
//
//
//
//
/*  FUNCTIONS    ----------------------------------------------------------- */








//	/// function used to create a new drawing space
//public: static CCERR::EERRORS		create		(
//		CC_Draw*		pDraw,	/**< pointer to container; may be NULL */
//		CC_DrawSpace*	pTmpl,	/**< pointer to space used as template; may be NULL */
//		QString			strNewName,/**< name of this space; must be either an empty
//	 string or an unique name*/
//		CC_DrawSpace**	pOut,	/**< if succesfull, pointer to created layer */
//		CC_Err*			pErr	/**< pointer to error correlation structure */
//		);

//	/// associates an unbound drawing space with a drawing
//	/**
//	*	Unbound spaces reslut from using CC_DrawSpace::create without a drawing as
//	*	argument.
//	*/
//public: CCERR::EERRORS				bind		(
//		CC_Draw*		pDraw,	/**< pointer to container; must not be NULL */
//		CC_Err*			pErr	/**< pointer to error correlation structure */
//		);


/* ------------------------------------------------------------------------- */
/* actual constructor	                                                     */
CCERR::EERRORS		CC_DrawSpace::create	(CC_Draw* pDraw, CC_DrawSpace* pTpl,
											 QString strNewName,
											 CC_DrawSpace** pOut, CC_Err* pErr)
	{

	CCERR::EERRORS		bRet = CCERR::ERR_SUCCESS;

	/* first, create the empty object in memory */
	CC_DrawSpace*	pRetSpc = new CC_DrawSpace();
	pRetSpc->pAscDraw = pDraw;


	if (pDraw == NULL)
		{
		if (pTpl != NULL)
			{
			pErr->Add(CCERR::EWAR_IN, CCERR::CTX_DRAWINT,
					  TR::tr("Create space: Template may be used only with associated drawing"));

			}
		}
	else
		{
		Q_ASSERT(pDraw->InitOk());

		/* associate the space with drawing */
		pDraw->Spaces.append(pRetSpc);


		if (pTpl != NULL)
			{ /* import properties from template */
			pRetSpc->grd = pTpl->grd;
			}
		else
			{ /* be shure that it has an graphic object associated */
			bRet = CC_GIP::GetGenericItem(pDraw, &pRetSpc->grd, pErr);
			if (!SUCCEDED(bRet))
				{
				pErr->Add(CCERR::EERR_IN, CCERR::CTX_DRAWINT,
						  TR::tr("Create space: Could not get a graphic object"));
				delete(pRetSpc);
				return bRet;
				}
			}

		/* todo signal to interested parties that a change took place in the
	struture of the drawing */

		}

	/* tell the user the output of it's actions */
	if (pOut != NULL)
		*pOut = pRetSpc;

	return bRet;
	}
/* ========================================================================= */



/* ------------------------------------------------------------------------- */
/* saves the data regarding this class to a stream in CASP_1 format          */
CCERR::EERRORS		CC_DrawSpace::Save_CASP_1	(QDataStream* pStream, CC_Err* pErr)
{
	Q_UNUSED(pStream);
	Q_UNUSED(pErr);
	CCERR::EERRORS		bRet = CCERR::ERR_SUCCESS;


	return bRet;
}
/* ========================================================================= */

/* ------------------------------------------------------------------------- */
/* loads the data regarding this class from a stream in CASP_1 format        */
CCERR::EERRORS		CC_DrawSpace::Load_CASP_1	(QDataStream* pStream, CC_Err* pErr)
{
	Q_UNUSED(pStream);
	Q_UNUSED(pErr);
	CCERR::EERRORS		bRet = CCERR::ERR_SUCCESS;


	return bRet;
}
/* ========================================================================= */


/* ------------------------------------------------------------------------- */
/* saves the data regarding this class to a stream in CASP_1 format          */
CCERR::EERRORS		CC_DrawSpace::Save_DXF	(QDataStream* pStream, CC_Err* pErr)
{
	Q_UNUSED(pStream);
	Q_UNUSED(pErr);
	CCERR::EERRORS		bRet = CCERR::ERR_SUCCESS;


	return bRet;
}
/* ========================================================================= */

/* ------------------------------------------------------------------------- */
/* loads the data regarding this class from a stream in CASP_1 format        */
CCERR::EERRORS		CC_DrawSpace::Load_DXF	(QDataStream* pStream, CC_Err* pErr)
{
	Q_UNUSED(pStream);
	Q_UNUSED(pErr);
	CCERR::EERRORS		bRet = CCERR::ERR_SUCCESS;


	return bRet;
}
/* ========================================================================= */

/*  FUNCTIONS    =========================================================== */
//
//
//
//
/* ------------------------------------------------------------------------- */
/* ========================================================================= */
